<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" type="text/css" href="../css/loginRegister.css"/>
  <script src="../js/v3.2.8/vue.global.prod.js"></script>
  <script type="text/javascript" src="../js/jquery-1.8.0.min.js" ></script>
  <script src="../js/axios-0.27.2.js"></script>
<!--  <script src="js/bootstrap.min.js"></script>-->
  <title>管理员登录页</title>
</head>
<body id="panel">
<form id="app">
  <p>
    <input type="text" name="yhm" placeholder="账号" v-model="user.uid"/>
  </p>
  <p>
    <input type="password" name="pwd" placeholder="密码" v-model="user.pwd"/>
  </p>
  <p>
    <input type="button" value="登录" id="login" @click="vuedologin()"  />
  </p>
</form>

</body>
<script>
  Vue.createApp({
    data(){
      return {
        user:{}
      }
    },
    methods:{
      vuedologin(){
        var _this=this;
        console.log(_this.user);
          axios({
            type: 'post',
            url: '/users/ManagerLogin',
            params: {
              uid: _this.user.uid,
              pwd: _this.user.pwd
            }
          }).then(res =>{
            let user = res.data;
            if (null != user && "" != user) {
              if (0 === user.data.level) {
                // 是普通用户（买家），则跳转到用户界面
                localStorage.setItem("Manager",this.user.uid);
                location = "admin.html";
              } else {
                // 用户身份不明确者，跳转到网站主页
                alert("身份错误，不为管理员")
              }
            } else {
              alert("用户名或密码错误");
            }
          })
        }
      },
    }).mount("#app");
</script>
</html>